﻿using RayDen.RayEngine.Core;
using RayDen.RayEngine.Core.Interface;
using RayDen.RayEngine.Managers;
using RayDen.RayEngine.Samplers;

namespace RayDen.RayEngine
{
    public class DeviceRenderThread<TPathBuffer> : GenericDeviceRenderThreadBase<TPathBuffer, IImageFilm>
        where TPathBuffer : PathBufferBase, new()
    {

        protected new RayEngineScene scene;
        protected DeviceRenderThread(int index, RayEngineScene scene)
            : base(index, scene)
        {
            this.scene = scene;
        }

        public DeviceRenderThread(int index, IIntersectionEngine device, RayEngineScene scn, bool lowLatency, IImageFilm pixelDevice, SamplingContext sc, IFrameManager fM)
            : base(index, device, scn, lowLatency, pixelDevice, sc, fM)
        {
            //Init(device, lowLatency, pixelDevice, sc);
        }

        protected override TPathBuffer CreatePathBuffer(int maxPath, RayEngineScene scene, IImageFilm pixelDevice, SamplingContext sc)
        {
            var pathBuffer = new TPathBuffer()
            {
                Sampler = sc.PrimarySpaceSampler, 
                lightSampler = (LightSampler)sc.LightSampler, 
                surfaceSampler = (SurfaceSampler)sc.SurfaceSampler
            };
            pathBuffer.Init(maxPath, scene, pixelDevice, sc);
            return pathBuffer;
        }
    }

}